/*
 * Copyright 2012 ITC Tsinghua University. All Rights Reserved.
 */
package cn.edu.tsinghua.cic.ccss.qo;

import org.forten.core.dao.rdb.hibernate.QueryInfo;
import org.forten.core.dao.rdb.query.Operator;
import org.forten.core.qo.QueryEntity;
import org.forten.core.qo.QueryField;
import org.forten.core.qo.QueryObject;
import org.forten.utils.common.StringUtil;
import org.forten.utils.security.MD5Util;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cn.edu.tsinghua.cic.ccss.entity.Cadre;

/**
 * 
 * 
 * @author <a href="mailto:du_yi@bbn.cn">Duyi</a>
 * 
 * @since 2012-5-8
 */
@QueryEntity(Cadre.class)
@Component("cadreListQo")
@Scope("prototype")
public class CadreListQo implements QueryObject {
	private String cardNum;
	private String name;
	private String jobLevel;
	@QueryField(fieldName = "cardNumMD5", paramName = "cardNum", operator = Operator.EQ)
	private String cardNumMD5;
	@QueryField(fieldName = "nameMD5", paramName = "name", operator = Operator.EQ)
	private String nameMD5;
	@QueryField(fieldName = "jobLevelMD5", paramName = "jobLevel", operator = Operator.EQ)
	private String jobLevelMD5;

	public String getCardNum() {
		return cardNum;
	}

	public void setCardNum(String cardNum) {
		if (StringUtil.hasText(cardNum)) {
			this.cardNumMD5 = MD5Util.encrypt(cardNum);
		} else {
			this.cardNumMD5 = "";
		}
		this.cardNum = cardNum;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if (StringUtil.hasText(name)) {
			this.nameMD5 = MD5Util.encrypt(name);
		} else {
			this.nameMD5 = "";
		}
		this.name = name;
	}

	public String getJobLevel() {
		return jobLevel;
	}

	public void setJobLevel(String jobLevel) {
		if (StringUtil.hasText(jobLevel)) {
			this.jobLevelMD5 = MD5Util.encrypt(jobLevel);
		} else {
			this.jobLevelMD5 = "";
		}
		this.jobLevel = jobLevel;
	}

	/**
	 * @return the cardIdMD5
	 */
	public String getCardNumMD5() {
		return cardNumMD5;
	}

	/**
	 * @return the nameMD5
	 */
	public String getNameMD5() {
		return nameMD5;
	}

	/**
	 * @return the jobLevelMD5
	 */
	public String getJobLevelMD5() {
		return jobLevelMD5;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.forten.core.qo.QueryObject#beforeBuildQueryInfo()
	 */
	@Override
	public void beforeBuildQueryInfo() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.forten.core.qo.QueryObject#afterBuildQueryInfo(org.forten.core.dao
	 * .rdb.hibernate.QueryInfo)
	 */
	@Override
	public QueryInfo afterBuildQueryInfo(QueryInfo qi) {
		return qi;
	}

	@Override
	public String toString() {
		return "CadreListQo [cardNum=" + cardNum + ", name=" + name
				+ ", jobLevel=" + jobLevel + ", cardNumMD5=" + cardNumMD5
				+ ", nameMD5=" + nameMD5 + ", jobLevelMD5=" + jobLevelMD5 + "]";
	}

	public void clean() {
		this.cardNum = null;
		this.cardNumMD5 = null;
		this.name = null;
		this.nameMD5 = null;
		this.jobLevel = null;
		this.jobLevelMD5 = null;
	}
}
